//
//  UIButton+Extensions.swift
//  WeiBoApp
//
//  Created by CrazyHacker on 16/7/1.
//  Copyright © 2016年 CrazyHacker. All rights reserved.
//

import Foundation
extension UIButton {
    convenience init(frame: CGRect, title: String, textColor:UIColor = UIColor.darkGray(),titleColorNormal:UIColor = UIColor.darkGray(),titleColorHighlighted:UIColor = UIColor.black(), image:UIImage) {
     let button = UIButton()
        button.frame = frame
        button.setTitle(title, for: UIControlState(rawValue:0))
        button.setTitleColor(titleColorNormal, for: UIControlState(rawValue:0))
        button.setTitleColor(titleColorHighlighted, for: .highlighted)
        button.titleLabel?.textAlignment = .center
        button.titleLabel?.textColor = textColor
        button.imageView?.image = image
    
        self.init()
    }
}
// Self.init isn't called on all paths before returning from initializer
// 在返回初始化器方法之前, self.init 在任何途径下都没有被调用 ==> 需要self.init()
